package com.bruan.d1_io;

import java.io.FileInputStream;
import java.io.InputStream;

public class FileInputStreamTest3 {
    public static void main(String[] args) throws Exception {
        //一次性读取完文件
        InputStream fi = new FileInputStream("file-io-app\\bruan.txt");
        //方法一：准备一个桶跟文件大小一样大
//        File file = new File("file-io-app\\bruan.txt");
//        byte[] buffer = new byte[(int) file.length()];
//
//        int len = fi.read(buffer);
//        String s = new String(buffer);
//        System.out.println(len);
//        System.out.println(s);
//        System.out.println(file.length());

        //方法二
        byte[] bytes = fi.readAllBytes();
        System.out.println(new String(bytes));



    }
}
